/**
 * Created by yangchen on 2017-09-18.
 */
$(document).ready(
    function () {
        var $dialog = weui.dialog({
            title: "我就是想导出",
            content: "<div>" +
            "<input type='text' maxlength='11' class='input' id='phone' placeholder='请输入手机号'>"+
            "<input type='password' maxlength='11' class='input' id='psw' placeholder='请输入密码'>"+
            "<button class='weui-btn weui-btn_mini weui-btn_primary' onclick='exportLeaders()'>推荐人榜单</button>"+
            "<button class='weui-btn weui-btn_mini weui-btn_primary' style='margin-left: 20px;' onclick='exportPresentee()'>被推荐人名单</button>"+
            "</div>",
            className: 'custom-classname',
            close:false
        });
});

function constructQueryString(obj) {
    return Object.entries(obj).reduce(function(pre, cur){
        cur[1] && pre.push(cur[0]+'='+cur[1]);
        return pre
    }, []).join('&')
}
var data = {
    phone:$('#phone').val(),
    psw:$('#psw').val()
};

var exportLeaders = function () {
    window.location = '/leadership/report/exportLeadersXLS'+constructQueryString(data);
};

var exportPresentee = function () {
    window.location = '/leadership/report/exportPresenteeXLS'+constructQueryString(data);
};

